<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Class: WePay::Client
  
    &mdash; WePay Signer for Ruby
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  pathId = "WePay::Client";
  relpath = '../';
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div class="nav_wrap">
      <iframe id="nav" src="../class_list.html"></iframe>
      <div id="resizer"></div>
    </div>

    <div id="main" tabindex="-1">
      <div id="header">
        <div id="menu">
  
    <a href="../_index.html">Index (C)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../WePay.html" title="WePay (module)">WePay</a></span></span>
     &raquo; 
    <span class="title">Client</span>
  
</div>

        <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">

        <svg width="24" height="24">
          <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
        </svg>
    </a>
  
</div>
        <div class="clear"></div>
      </div>

      <iframe id="search_frame" src="../class_list.html"></iframe>

      <div id="content"><h1>Class: WePay::Client
  
  
  
</h1>
<div class="box_info">
  
  <dl>
    <dt>Inherits:</dt>
    <dd>
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">WePay::Client</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
    </dd>
  </dl>
  

  
  
  
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/wepay.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>A very simple wrapper for the WePay API.</p>


  </div>
</div>
<div class="tags">
  

</div>
  <h2>Constant Summary</h2>
  
    <dl class="constants">
      
        <dt id="STAGE_API_ENDPOINT-constant" class="">STAGE_API_ENDPOINT =
          <div class="docstring">
  <div class="discussion">
    <p>Stage API endpoint</p>


  </div>
</div>
<div class="tags">
  

</div>
        </dt>
        <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://stage.wepayapi.com/v2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
      
        <dt id="STAGE_UI_ENDPOINT-constant" class="">STAGE_UI_ENDPOINT =
          <div class="docstring">
  <div class="discussion">
    <p>Stage UI endpoint</p>


  </div>
</div>
<div class="tags">
  

</div>
        </dt>
        <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://stage.wepay.com/v2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
      
        <dt id="PRODUCTION_API_ENDPOINT-constant" class="">PRODUCTION_API_ENDPOINT =
          <div class="docstring">
  <div class="discussion">
    <p>Production API endpoint</p>


  </div>
</div>
<div class="tags">
  

</div>
        </dt>
        <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://wepayapi.com/v2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
      
        <dt id="PRODUCTION_UI_ENDPOINT-constant" class="">PRODUCTION_UI_ENDPOINT =
          <div class="docstring">
  <div class="discussion">
    <p>Production UI endpoint</p>


  </div>
</div>
<div class="tags">
  

</div>
        </dt>
        <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://www.wepay.com/v2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
      
    </dl>
  




  <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#api_endpoint-instance_method" title="#api_endpoint (instance method)">#<strong>api_endpoint</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the value of attribute api_endpoint.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#api_version-instance_method" title="#api_version (instance method)">#<strong>api_version</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the value of attribute api_version.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#client_id-instance_method" title="#client_id (instance method)">#<strong>client_id</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the value of attribute client_id.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#client_secret-instance_method" title="#client_secret (instance method)">#<strong>client_secret</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the value of attribute client_secret.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ui_endpoint-instance_method" title="#ui_endpoint (instance method)">#<strong>ui_endpoint</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the value of attribute ui_endpoint.</p>
</div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(call, access_token = false, params = {})  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Execute a call to the WePay API.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(client_id, client_secret, use_stage = true, api_version = nil)  &#x21d2; Client </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>A new instance of Client.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#oauth2_authorize_url-instance_method" title="#oauth2_authorize_url (instance method)">#<strong>oauth2_authorize_url</strong>(redirect_uri, user_email = false, user_name = false, permissions = &quot;manage_accounts,collect_payments,view_user,send_money,preapprove_payments,manage_subscriptions&quot;, user_country = false)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the OAuth 2.0 URL that users should be redirected to for authorizing your API application.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#oauth2_token-instance_method" title="#oauth2_token (instance method)">#<strong>oauth2_token</strong>(code, redirect_uri)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Call the <code>/v2/oauth2/token</code> endpoint to exchange an OAuth 2.0 <code>code</code> for an <code>access_token</code>.</p>
</div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    #<strong>initialize</strong>(client_id, client_secret, use_stage = true, api_version = nil)  &#x21d2; <tt><span class='object_link'><a href="" title="WePay::Client (class)">Client</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns a new instance of Client</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


42
43
44
45
46
47
48
49
50
51
52
53
54</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 42</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_client_id'>client_id</span><span class='comma'>,</span> <span class='id identifier rubyid_client_secret'>client_secret</span><span class='comma'>,</span> <span class='id identifier rubyid_use_stage'>use_stage</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_api_version'>api_version</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='ivar'>@client_id</span>     <span class='op'>=</span> <span class='id identifier rubyid_client_id'>client_id</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
  <span class='ivar'>@client_secret</span> <span class='op'>=</span> <span class='id identifier rubyid_client_secret'>client_secret</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
  <span class='ivar'>@api_version</span>   <span class='op'>=</span> <span class='id identifier rubyid_api_version'>api_version</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_use_stage'>use_stage</span>
    <span class='ivar'>@api_endpoint</span> <span class='op'>=</span> <span class='const'>STAGE_API_ENDPOINT</span>
    <span class='ivar'>@ui_endpoint</span>  <span class='op'>=</span> <span class='const'>STAGE_UI_ENDPOINT</span>
  <span class='kw'>else</span>
    <span class='ivar'>@api_endpoint</span> <span class='op'>=</span> <span class='const'>PRODUCTION_API_ENDPOINT</span>
    <span class='ivar'>@ui_endpoint</span>  <span class='op'>=</span> <span class='const'>PRODUCTION_UI_ENDPOINT</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id=""></span>
      <div class="method_details first">
  <h3 class="signature first" id="api_endpoint-instance_method">
  
    #<strong>api_endpoint</strong>  &#x21d2; <tt>Object</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the value of attribute api_endpoint</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


36
37
38</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 36</span>

<span class='kw'>def</span> <span class='id identifier rubyid_api_endpoint'>api_endpoint</span>
  <span class='ivar'>@api_endpoint</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <div class="method_details ">
  <h3 class="signature " id="api_version-instance_method">
  
    #<strong>api_version</strong>  &#x21d2; <tt>Object</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the value of attribute api_version</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


37
38
39</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 37</span>

<span class='kw'>def</span> <span class='id identifier rubyid_api_version'>api_version</span>
  <span class='ivar'>@api_version</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <div class="method_details ">
  <h3 class="signature " id="client_id-instance_method">
  
    #<strong>client_id</strong>  &#x21d2; <tt>Object</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the value of attribute client_id</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


38
39
40</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 38</span>

<span class='kw'>def</span> <span class='id identifier rubyid_client_id'>client_id</span>
  <span class='ivar'>@client_id</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <div class="method_details ">
  <h3 class="signature " id="client_secret-instance_method">
  
    #<strong>client_secret</strong>  &#x21d2; <tt>Object</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the value of attribute client_secret</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


39
40
41</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 39</span>

<span class='kw'>def</span> <span class='id identifier rubyid_client_secret'>client_secret</span>
  <span class='ivar'>@client_secret</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <div class="method_details ">
  <h3 class="signature " id="ui_endpoint-instance_method">
  
    #<strong>ui_endpoint</strong>  &#x21d2; <tt>Object</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the value of attribute ui_endpoint</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


40
41
42</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 40</span>

<span class='kw'>def</span> <span class='id identifier rubyid_ui_endpoint'>ui_endpoint</span>
  <span class='ivar'>@ui_endpoint</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="call-instance_method">
  
    #<strong>call</strong>(call, access_token = false, params = {})  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Execute a call to the WePay API.</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 59</span>

<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_call'>call</span><span class='comma'>,</span> <span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_call'>call</span> <span class='op'>:</span> <span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_prepend'>prepend</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
  <span class='id identifier rubyid_url'>url</span>  <span class='op'>=</span> <span class='const'>URI</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_api_endpoint'>api_endpoint</span> <span class='op'>+</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>

  <span class='id identifier rubyid_call'>call</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Post</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='lbrace'>{</span>
    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Content-Type</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>application/json</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>User-Agent</span><span class='tstring_end'>&#39;</span></span>   <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>WePay Ruby SDK</span><span class='tstring_end'>&#39;</span></span>
  <span class='rbrace'>}</span><span class='rparen'>)</span>

  <span class='kw'>unless</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
    <span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
  <span class='kw'>end</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_access_token'>access_token</span> <span class='kw'>then</span> <span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_add_field'>add_field</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Authorization</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Bearer </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_access_token'>access_token</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>
  <span class='kw'>if</span> <span class='ivar'>@api_version</span> <span class='kw'>then</span> <span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_add_field'>add_field</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Api-Version</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='ivar'>@api_version</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>

  <span class='id identifier rubyid_make_request'>make_request</span><span class='lparen'>(</span><span class='id identifier rubyid_call'>call</span><span class='comma'>,</span> <span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="oauth2_authorize_url-instance_method">
  
    #<strong>oauth2_authorize_url</strong>(redirect_uri, user_email = false, user_name = false, permissions = &quot;manage_accounts,collect_payments,view_user,send_money,preapprove_payments,manage_subscriptions&quot;, user_country = false)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the OAuth 2.0 URL that users should be redirected to for
authorizing your API application. The <code>redirect_uri</code> must be a
fully-qualified URL (e.g., <code>https://www.wepay.com</code>).</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 83</span>

<span class='kw'>def</span> <span class='id identifier rubyid_oauth2_authorize_url'>oauth2_authorize_url</span><span class='lparen'>(</span>
  <span class='id identifier rubyid_redirect_uri'>redirect_uri</span><span class='comma'>,</span>
  <span class='id identifier rubyid_user_email'>user_email</span>   <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span>
  <span class='id identifier rubyid_user_name'>user_name</span>    <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span>
  <span class='id identifier rubyid_permissions'>permissions</span>  <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>manage_accounts,collect_payments,view_user,send_money,preapprove_payments,manage_subscriptions</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
  <span class='id identifier rubyid_user_country'>user_country</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='rparen'>)</span>
  <span class='id identifier rubyid_url'>url</span> <span class='op'>=</span> <span class='ivar'>@ui_endpoint</span> <span class='op'>+</span>
        <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/oauth2/authorize?client_id=</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='ivar'>@client_id</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span>
        <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&amp;redirect_uri=</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='id identifier rubyid_redirect_uri'>redirect_uri</span> <span class='op'>+</span>
        <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&amp;scope=</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='id identifier rubyid_permissions'>permissions</span>

  <span class='id identifier rubyid_url'>url</span> <span class='op'>+=</span> <span class='id identifier rubyid_user_name'>user_name</span> <span class='op'>?</span>    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&amp;user_name=</span><span class='tstring_end'>&#39;</span></span>    <span class='op'>+</span> <span class='const'>CGI</span><span class='op'>::</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='id identifier rubyid_user_name'>user_name</span><span class='rparen'>)</span>    <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
  <span class='id identifier rubyid_url'>url</span> <span class='op'>+=</span> <span class='id identifier rubyid_user_email'>user_email</span> <span class='op'>?</span>   <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&amp;user_email=</span><span class='tstring_end'>&#39;</span></span>   <span class='op'>+</span> <span class='const'>CGI</span><span class='op'>::</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='id identifier rubyid_user_email'>user_email</span><span class='rparen'>)</span>   <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
  <span class='id identifier rubyid_url'>url</span> <span class='op'>+=</span> <span class='id identifier rubyid_user_country'>user_country</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&amp;user_country=</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='const'>CGI</span><span class='op'>::</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='id identifier rubyid_user_country'>user_country</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="oauth2_token-instance_method">
  
    #<strong>oauth2_token</strong>(code, redirect_uri)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Call the <code>/v2/oauth2/token</code> endpoint to exchange an OAuth 2.0 <code>code</code> for an <code>access_token</code>.</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


103
104
105
106
107
108
109
110</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/wepay.rb', line 103</span>

<span class='kw'>def</span> <span class='id identifier rubyid_oauth2_token'>oauth2_token</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span><span class='comma'>,</span> <span class='id identifier rubyid_redirect_uri'>redirect_uri</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/oauth2/token</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='lbrace'>{</span>
    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>client_id</span><span class='tstring_end'>&#39;</span></span>     <span class='op'>=&gt;</span> <span class='ivar'>@client_id</span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>client_secret</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='ivar'>@client_secret</span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>redirect_uri</span><span class='tstring_end'>&#39;</span></span>  <span class='op'>=&gt;</span> <span class='id identifier rubyid_redirect_uri'>redirect_uri</span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>code</span><span class='tstring_end'>&#39;</span></span>          <span class='op'>=&gt;</span> <span class='id identifier rubyid_code'>code</span>
  <span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Sat Jun 11 13:22:28 2016 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.6 (ruby-2.3.1).
</div>

    </div>
  </body>
</html>